<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="80px">
          <el-row>
            <el-col :span="5">
              <el-form-item label="门店" prop="storeId">
                <el-select
                  v-model="queryParams.storeId"
                  placeholder="请选择"
                  @change="SelectUser"
                  filterable
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item prop="userId" label="技师名称">
                <el-select
                  v-model="queryParams.userId"
                  filterable
                  placeholder="请选择技师"
                >
                  <el-option
                    v-for="item in usersList"
                    :key="item.userId"
                    :label="item.nickname"
                    :value="item.userId"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="时间" prop="time">
                <el-date-picker
                  v-model="queryParams.time"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>

    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left"></span>
        <div class="table_card_title">人员提成日统计</div>
        <div class="op_right"></div>
      </div>

      <div class="table_list">
        <el-table
          :data="DayList"
          stripe
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column prop="storeName" label="店铺名称"> </el-table-column>
          <el-table-column prop="userName" label="技师名称"> </el-table-column>
          <el-table-column prop="awardTotalVisitor" label="约客提成">
          </el-table-column>
          <el-table-column prop="awardTotalWork" label="加班提成">
          </el-table-column>
          <el-table-column prop="awardTotalCardMoney" label="充卡金额">
          </el-table-column>
          <el-table-column prop="awardTotalClockAdd" label="加钟提成">
          </el-table-column>
          <el-table-column prop="awardTotalClockSpot" label="点钟提成">
          </el-table-column>
          <el-table-column prop="awardTotalDate" label="日期">
          </el-table-column>
          <el-table-column prop="awardTotalHand" label="手工提成">
          </el-table-column>
          <el-table-column prop="awardTotalHospitality" label="待客提成">
          </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNo"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { getStoreUser, getStoreInfoList, getDay } from "@/api/bpm/handmade";
export default {
  name: "Storeadminpersonnelday",

  data() {
    return {
      DayList: [], // 技师手工
      loading: false,

      queryTypeOptions: [],
      value: "",
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        storeId: "",
        time: [],
        userId: "",
      },
      total: 0,
      usersList: [],
    };
  },

  mounted() {},

  created() {
    this.getList();
    this.getStorelist();
  },

  methods: {
    SelectUser() {
      this.getUsers();
    },
    getUsers() {
      getStoreUser({
        filterUser: "N",
        storeId: this.queryParams.storeId,
      })
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.usersList = data;
          }
        })
        .catch((err) => {});
    },

    // 门店
    getStorelist() {
      getStoreInfoList({})
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.queryTypeOptions = data;
          }
        })
        .catch((err) => {});
    },

    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$refs[formName].resetFields();
    },

    // 人员提成日统计
    getList() {
      this.loading = true;
      let queryParams = JSON.parse(JSON.stringify(this.queryParams));

      if (!!this.queryParams.time) {
        queryParams.startDate = this.queryParams.time[0];
        queryParams.endDate = this.queryParams.time[1];
      }

      getDay(queryParams)
        .then((res) => {
          // console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.DayList = data.list;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: -50px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

.order_ipt {
  margin-left: -120px;
}
</style>
